﻿#ifndef MUSICPLAYER_H
#define MUSICPLAYER_H

#include <QWidget>
#include <QFileDialog>
#include <QtSql>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QVariant>
#include <QMessageBox>
#include <QDateTime>


/*-------- 加入多媒体头文件 --------*/
#include <QMediaPlayer>
#include <QMediaPlaylist>
/*----------------- HTTP相关 --------------------------*/
#include <QNetworkAccessManager>    //HTTP网络管理类
#include <QNetworkRequest>          //HTTP网络请求信息类
#include <QNetworkReply>            //HTTP网络响应类
#include <QUrl>                     //超链接类
#include <QUrlQuery>

/*----------------- QJSON相关 --------------------------*/
#include <QJsonDocument>            //解析
#include <QJsonObject>              //对象
#include <QJsonArray>               //数组
#include <QJsonValue>               //变量值



#include <QStandardItemModel>
#include <QList>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QMessageBox>

#include <QJsonArray>
#include <QFile>
#include <QJsonDocument>

QT_BEGIN_NAMESPACE
namespace Ui { class MusicPlayer; }
QT_END_NAMESPACE

struct MusicData
{
    QString MusicName;  //歌曲名
    QString MusicID;    //歌曲ID
    QString MusicAuthor;//歌曲作者
    QString AuthorID;   //作者ID

};

class MusicPlayer : public QWidget
{
    Q_OBJECT
public:
    explicit MusicPlayer(QWidget *parent = nullptr);
    ~MusicPlayer();

public:
    void setUIInit();   //UI界面的初始化
    void connectInit(); //信号槽初始化


    QStandardItemModel * pModel;
    QNetworkAccessManager *manager;
    void parseJson(QByteArray byteArray);

    void initTrayIcon();        //初始化
    void quitmucisPlayer();     //退出

signals:
 void lyricShow(QString url);

public slots:
    void replyFinished(QNetworkReply *reply);
protected slots:

private slots:
void lyricTextShow(QString str);
    //void on_horizontalSlider_speed_valueChanged(int value);
    //void set_sider(qint64 duration);
    //void set_value(qint64 position);
    void on_findpushButton_clicked();

    void on_musicTableView_doubleClicked(const QModelIndex &index);

    //void on_horizontalSlider_sliderPressed();

    void updateDuration(qint64 value);

    void on_hs_songtime_sliderReleased();



    void on_hs_songtime_valueChanged(int value);

    void on_hs_songtime_sliderPressed();

private:
    Ui::MusicPlayer *ui;
    QMediaPlayer *player;
    QMediaPlaylist *playlist;
    QNetworkAccessManager *m_http;
    QNetworkAccessManager *m_http_Music;
    QList<MusicData> MuSics;

    QSqlDatabase db1;//数据库操作类
    QString isSame = "";

    QList<int> musicIDList;
    bool canchange;                             //用于拖动进度条
QString music_duration;

};
#endif // MUSICPLAYER_H
